﻿using System;
using Common.Logging;
using InDbContext;

namespace In.Api.Helpers
{
    public class HospSpLogHelper
    {
        private static readonly ILog Logger = LogManager.GetLogger(typeof(HospWsLogHelper));

        public static void Log(string type, string request, string response)
        {
            Logger.InfoFormat("调用{0}，request:{1} response:{2}", type, request, response);

            using (var ctx = new HospDatabaseEntity())
            {
                var log = new Log
                {
                    Action = type,
                    Request = request,
                    Response = response,
                    CreateDT = DateTime.Now
                };
                ctx.Logs.Add(log);
                ctx.SaveChanges();
            }
        }
    }
}
